﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WpfSnqkGasAnalysis.IData_impl;
using WpfSnqkGasAnalysis.Model;

namespace WpfSnqkGasAnalysis.IBusiness_impl
{
    /// <summary>
    /// 业务处理，基类。提供共有方法
    /// </summary>
    /// 创建时间：2022-12-7 21:31:20。作者：王浩力
    public class BaseBusiness
    {
        /// <summary>
        /// 当前登录用户
        /// </summary>
        /// 创建时间：2022-12-7 21:31:20。作者：王浩力
        public Login_user CurrentLoginUser
        {
            get
            {
                //获取当前登录用户
                var user = System.Runtime.Caching.MemoryCache.Default.Get(CommonConfig.LoginUserCacheKey) as Login_user;
                return user;
            }
        }

        /// <summary>
        /// 开启事务。
        /// </summary>
        /// <returns></returns>
        /// 创建时间：2022-12-11 23:41:36。作者：王浩力
        //protected IResult BeginTransaction()
        //{
        //    BaseDAL baseDAL = new BaseDAL();
        //    int count = baseDAL.ExecSqlCmd("begin;", null, c =>
        //    {
        //        return c.ExecuteNonQuery();
        //    });
        //    return count > 0 ? new ResultSuccess() : new Result("事务开启失败");
        //}

        /// <summary>
        /// 提交事务
        /// </summary>
        /// <returns></returns>
        //protected IResult CommitTransaction()
        //{
        //    BaseDAL baseDAL = new BaseDAL();
        //    int count = baseDAL.ExecSqlCmd("COMMIT;", null, c =>
        //    {
        //        return c.ExecuteNonQuery();
        //    });
        //    return count > 0 ? new ResultSuccess() : new Result("提交事务");
        //}

        ///// <summary>
        ///// 回滚事务
        ///// </summary>
        ///// <returns></returns>
        ///// 创建时间：2022-12-11 23:41:20。作者：王浩力
        //protected IResult RollbackTransaction()
        //{
        //    BaseDAL baseDAL = new BaseDAL();
        //    int count = baseDAL.ExecSqlCmd("ROLLBACK;", null, c =>
        //    {
        //        return c.ExecuteNonQuery();
        //    });
        //    return count > 0 ? new ResultSuccess() : new Result("回滚事务");
        //}


    }
}
